package org.cerberus.platform.component.impl;

import java.util.List;

import org.cerberus.platform.component.ComponentUtilities;
import org.cerberus.platform.component.IPlatformContext;
import org.cerberus.platform.component.annotations.PAttribute;
import org.cerberus.platform.component.annotations.Event;
import org.cerberus.platform.component.annotations.FetchType;
import org.cerberus.platform.component.annotations.InjectPlatformContext;
import org.cerberus.platform.component.annotations.PComponent;
import org.cerberus.platform.component.annotations.ResourceBundle;
import org.cerberus.platform.component.annotations.ResourceList;

@PComponent(classID="MyClientID")
@ResourceList(MyResourceList.class)
@ResourceBundle("messages")
public class MyComponent extends ComponentBase {

	public static final String ATTRIBUTE_ATTRIBUTE = "attribute";
	public static final String ATTRIBUTE_LIST = "anotherName";
	public static final String EVENT_DEMO_EVENT = "demoEvent";
	
	@PAttribute(name=ATTRIBUTE_ATTRIBUTE)
	private String attribute;
	
	@PAttribute(name=ATTRIBUTE_LIST , fetch=FetchType.LAZY)
	private List<String> list;
	
	@InjectPlatformContext
	private IPlatformContext context;
	
	@PAttribute
	private MySubComponent subComponent;
	
	@PAttribute
	private List<MySubComponent> subComponentList;
	
	public String getAttribute() {
		return attribute;
	}

	public void setAttribute(String attribute) {
		this.attribute = attribute;
		ComponentUtilities.attributeChanged(this, ATTRIBUTE_ATTRIBUTE);
	}

	public List<String> getList() {
		return list;
	}

	public void setList(List<String> list) {
		this.list = list;
		ComponentUtilities.attributeChanged(this, ATTRIBUTE_LIST);
	}
	
	public List<MySubComponent> getSubComponentList() {
		return subComponentList;
	}

	public void setSubComponentList(List<MySubComponent> subComponentList) {
		this.subComponentList = subComponentList;
		ComponentUtilities.attributeChanged(this, "subComponentList");
	}

	public MySubComponent getSubComponent() {
		return subComponent;
	}

	public void setSubComponent(MySubComponent subComponent) {
		this.subComponent = subComponent;
		ComponentUtilities.attributeChanged(this, ATTRIBUTE_LIST);
	}

	@Event(name=EVENT_DEMO_EVENT)
	public Object demoEvent() {
		System.out.println("DEMO EVENT");
		return null;
	}
	
	
}
